/*     */ package com.newcrm.db;
/*     */ 
/*     */ import java.sql.Connection;
/*     */ import java.sql.SQLException;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.dbutils.DbUtils;
/*     */ import org.apache.commons.dbutils.MyMapListHandler;
/*     */ import org.apache.commons.dbutils.QueryRunner;
/*     */ import org.apache.commons.dbutils.handlers.MapHandler;
/*     */ import org.apache.log4j.Logger;
/*     */ 
/*     */ public class CompanyExtManager
/*     */ {
/*  18 */   private static Logger logger = Logger.getLogger(CompanyExtManager.class
/*  19 */     .getName());
/*     */ 
/*     */   public int update(int fieldType, String fieldValue, int companyId, String userId)
/*     */   {
/*  32 */     Connection conn = ConnectionManager.getInstance().getConnection();
/*  33 */     if (conn == null) {
/*  34 */       return 0;
/*     */     }
/*  36 */     QueryRunner runner = new QueryRunner();
/*     */     try {
/*  38 */       int num = runner.update(conn, "UPDATE T_Company_Ext_Info SET FieldValue = ?, UpdateUserId = ?, UpdateDate = NOW() WHERE CompanyId = ? AND FieldType = ?", new Object[] { 
/*  39 */         fieldValue, userId, Integer.valueOf(companyId), Integer.valueOf(fieldType) });
/*     */       int i;
/*  41 */       if (num == 1) {
/*  42 */         return num;
/*     */       }
/*     */ 
/*  46 */       return runner.update(conn, "INSERT INTO T_Company_Ext_Info (CompanyId, FieldType, FieldValue, CreateDate, CreateUserId) VALUES (?, ?, ?, NOW(), ?)", new Object[] { Integer.valueOf(companyId), 
/*  47 */         Integer.valueOf(fieldType), fieldValue, userId });
/*     */     }
/*     */     catch (SQLException e) {
/*  50 */       logger.warn("update company ext info failed", e);
/*     */     } finally {
/*     */       try {
/*  53 */         DbUtils.close(conn);
/*     */       } catch (SQLException e) {
/*  55 */         logger.warn("close conn failed", e);
/*     */       }
/*     */     }
/*  58 */     return 0;
/*     */   }
/*     */ 
/*     */   public String getFieldValue(int companyId, int fieldType)
/*     */   {
/*  69 */     Connection conn = ConnectionManager.getInstance().getConnection();
/*  70 */     if (conn == null) {
/*  71 */       return null;
/*     */     }
/*  73 */     QueryRunner runner = new QueryRunner();
/*     */     try
/*     */     {
/*  76 */       Map result = (Map)runner.query(conn, 
/*  77 */         "SELECT FieldValue FROM T_Company_Ext_Info WHERE CompanyId = ? AND FieldType = ?", new MapHandler(), new Object[] { Integer.valueOf(companyId), 
/*  78 */         Integer.valueOf(fieldType) });
/*  79 */       if (result == null) {
/*  80 */         return null;
/*     */       }
/*  82 */       return (String)result.get("FieldValue");
/*     */     } catch (SQLException e) {
/*  84 */       logger.warn("get company ext info failed", e);
/*     */     } finally {
/*     */       try {
/*  87 */         DbUtils.close(conn);
/*     */       } catch (SQLException e) {
/*  89 */         logger.warn("close conn failed", e);
/*     */       }
/*     */     }
/*  92 */     return null;
/*     */   }
/*     */ 
/*     */   public List<Map<String, Object>> getAllMaxNotContactDays()
/*     */   {
/* 101 */     Connection conn = ConnectionManager.getInstance().getConnection();
/* 102 */     if (conn == null) {
/* 103 */       return null;
/*     */     }
/*     */ 
/* 106 */     QueryRunner runner = new QueryRunner();
/*     */     try
/*     */     {
/* 109 */       return (List)runner.query(conn, 
/* 110 */         "SELECT CompanyId, FieldValue FROM T_Company_Ext_Info WHERE FieldType = ?", 
/* 111 */         new MyMapListHandler(), new Object[] { 
/* 112 */         Integer.valueOf(1) });
/*     */     } catch (SQLException e) {
/* 114 */       logger.warn("get all not contact days failed", e);
/*     */     } finally {
/*     */       try {
/* 117 */         DbUtils.close(conn);
/*     */       } catch (SQLException e) {
/* 119 */         logger.warn("close conn failed", e);
/*     */       }
/*     */     }
/* 122 */     return null;
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.db.CompanyExtManager
 * JD-Core Version:    0.6.1
 */